package roboticsfmw.sample;

import org.apache.log4j.BasicConfigurator;

import roboticsfmw.common.MainEngineProcessor;
import roboticsfmw.core.EngineRuntime;
import roboticsfmw.core.Timer;
import roboticsfmw.sample.event.SleepEvent;
import roboticsfmw.sample.hardware.UserIOHardwareProxy;
import roboticsfmw.sample.hardware.EyesHardwareProxy;
import roboticsfmw.sample.hardware.JoystickHardwareProxy;
import roboticsfmw.sample.processor.ArmProcessor;
import roboticsfmw.sample.processor.EyesProcessor;
import roboticsfmw.sample.sensor.JoystickSensor;
import roboticsfmw.sample.sensor.KeyboardCommandSensor;


public class MyRobot {

	public static void main(String[] args) {

		// it's necessary to provide some log4j configuration to engine
		BasicConfigurator.configure();

		EngineRuntime engine = new EngineRuntime();

		// registering hardware proxies
		engine.registerHardware("/hw/eyes", new EyesHardwareProxy());
		engine.registerHardware("/hw/joystick", new JoystickHardwareProxy());
		engine.registerHardware("/hw/userIO", new UserIOHardwareProxy());
		
		// registering sensors
		engine.registerSensor(new JoystickSensor("Joystick Sensor", 500, false));
		engine.registerSensor(new KeyboardCommandSensor("Keyboard Command Input", 100, true));
		
		// registering processors
		engine.registerProcessor(new MainEngineProcessor());
		engine.registerProcessor(new EyesProcessor("Robot Eyes Processor", 500, false));
		engine.registerProcessor(new ArmProcessor("Robot Arm Processor",500, false));
		
		// registering timers
		engine.registerTimer("/timer/InactivityTimer", new Timer("Inactivity Timer", 30000, new SleepEvent()));
		
		try {
			engine.startAll();
		} catch (Exception e) {
			e.printStackTrace();
			engine.shutdown();
		}

	}

}
